/**
 * @param {number[]} nums
 * @return {number[]}
 */
var productExceptSelf = function (nums) {
    const length = nums.length
    let arr = [1], reverseNum = 1
    for(let i = 1; i < length; i++) {
        arr[i] = arr[i - 1] * nums[i - 1]
    }
    for(let i = length - 2; i >= 0; i--) {
        reverseNum = reverseNum * nums[i + 1]
        arr[i] = arr[i] * reverseNum
    }
    return arr
};